<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>充电桩编号</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/2.4.1/weui.min.css"></link>
  <script src="../../static/js/jquery-1.8.1.min.js" ></script>
  <script src="../../static/js/weiXin.16.0.js" ></script>
  <script src="https://res.wx.qq.com/open/js/cloudbase/1.1.0/cloud.js"></script>
  <style>
	html{
		width:100%;
		height:100%;
		background-color:#eee;
	}
	.page{
		margin: 0 auto;
		text-align: center;
	}
	.wechat-web-container {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.wechat-web-container p {
		position: absolute;
		top: 220px;
		color:#000;
		background-color:#fff;
		border-radius:56px;
		width:90%;
		margin-left:5%;
		margin-right:5%;
		height:56px;
		line-height:56px;
		font-family:微软雅黑;
		font-weight:1000;
	}

	.wechat-web-container wx-open-launch-weapp {
		position: absolute;
		top: 294px;
		left: 0;
		right: 0;
		display: flex;
		flex-direction: column;
		align-items: center;
		font-family:微软雅黑
	}
	</style>  
</head>
<body>
<div class="page full">
	<div id="wechat-web-container" class="hidden wechat-web-container">
        <p id="show_info" ></p> <!-- replace -->
        <!-- 跳转小程序的开放标签。文档 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html -->
        <wx-open-launch-weapp id="launch-btn" username="gh_145e361d3f5f" path=""> <!-- replace -->
          <template>
            <button style="width: 90%; height: 56px; text-align: center; font-size: 18px; font-weight:1000; display: block; margin: 0 auto; padding: 8px 24px; border: none; border-radius: 56px; background-color: #000; color:#fff;">确 定</button>
          </template>
        </wx-open-launch-weapp>
     </div>
</div>
<script>
	var pNum = GetQueryString('pNum');
	var showInfo = document.getElementById('show_info');
	showInfo.innerHTML = pNum;
	var btn = document.getElementById('launch-btn');
	btn.setAttribute("path","/pages/index/pay?id="+pNum)
	btn.addEventListener('ready', function (e) {
        console.log('开放标签 ready')
    })
	btn.addEventListener('launch', function (e) {
		console.log('success');
	});
	btn.addEventListener('error', function (e) {
		console.log('fail', e.detail);
	});
	
	//数据设置
	var selfUrl = location.href;
	var ua = navigator.userAgent.toLowerCase();
	if (ua.match(/MicroMessenger/i) == "micromessenger") {
		console.log("/pages/index/pay?id="+pNum);
		let config={
			'debug':'',
			'appId':'',
			'timestamp':'',
			'nonceStr':'',
			'signature':'',
			'jsApiList':'',
			'openTagList':'',
		};
		$.ajax({url:"../index/weiXin/getWxConfig?web_url="+selfUrl,success:function(result){
			if(result.code == 0){
				backData = result.data;
				config.debug = backData.debug;
				config.appId = backData.appId;
				config.timestamp = backData.timestamp;
				config.nonceStr = backData.nonceStr;
				config.signature = backData.signature;
				config.jsApiList = backData.jsApiList;
				config.openTagList = ['wx-open-launch-weapp'];	
				wx.config(config);
				wx.ready(function () {
					//wx.miniProgram.navigateTo({url:"/pages/index/pay?id="+pNum});
				});
			}
		}});
		
	}else{
		console.log(11);
	}
	
	function GetQueryString(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
		var context = "";
		if (r != null)
			context = decodeURIComponent(r[2]);
		reg = null;
		r = null;
		return context == null || context == "" || context == "undefined" ? "" : context;
	}
</script>


</body>
</html>